package demo9;

import java.io.IOException;
import java.io.InputStream;

public class RuntimeDemo {

    public static void main(String[] args) throws IOException {
        Runtime runtime = Runtime.getRuntime();
        Process process = runtime.exec("java --version");
        InputStream is = process.getInputStream();
        // 创建足够大的字符数组
        byte[] bytes = new byte[1024 * 1024 * 100];
        // 获取读到的位数
        int len = is.read(bytes);
        // 转换为字符数组，设置编码（控制台默认GBK）
        System.out.println(new String(bytes, 0, len, "GBK"));
    }
}
